<%-------------------------------------------------------------------
 * 页面名称：drawToSelf_1.jsp
 * 功能描述：账户提现页面
 * Action: 
 *
 *-------------------------------------------------------------------
--%>
<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-tiles.tld" prefix="tiles"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-bean.tld" prefix="bean"%>
<%@ taglib prefix="ad" uri="agiledata"%>
<%
String path = request.getContextPath();
%>
<script type='text/javascript' src='<%=path%>/dwr/util.js'></script>
<script type='text/javascript' src='<%=path%>/js/ufront.js'></script>
<script type='text/javascript' src='<%=path%>/dwr/engine.js'></script>
<script type='text/javascript'
	src='<%=path%>/dwr/interface/accountTemplate.js'></script>
<script type='text/javascript' src='<%=path%>/js/vnv/commonForManage.js'></script>
<script type='text/javascript'
	src='<%=path%>/js/vnv/commonForCnAmount.js'></script>
<script type='text/javascript' src='<%=path%>/js/vnv/tomoney.js'></script>
<script language="JavaScript" type="text/JavaScript">
function submitProcess() {
	
		if(!checkNecessaryInput(document.forms[0]))
		{
		return;
		}else
		{
		var objSelect = document.getElementsByName("subAccountId")[0].value;
		accountTemplate.authentication(objSelect,showResult);
		}
}

function showResult(data)
{
	if(data=="true")
	{
		alert("您还未进行实名认证，不能使用该交易！");
		return;
	}else
	{
		var amount=document.getElementsByName("amount")[0].value;
		accountTemplate.confirmToRuleByDrawToSelf(amount,show);
	}
}
function show(data)
	{
		if(document.forms[0].remark.value.length>85){
			alert("备注长度不能大于85！");
			return false;
		}
	if("69"==data){
	   alert("违反单笔提现限额");
	   document.getElementsByName("amount")[0].focus();
	   return;
	}
	if("70"==data){
	   alert("违反每日提现限额");
	   document.getElementsByName("amount")[0].focus();
	   return;
	}
	if("71"==data){
	   alert("违反每月提现限额");
	   document.getElementsByName("amount")[0].focus();
	   return;
	}
			document.forms[0].submit();
	}
function updatePrompt(data) {
	if (data==2){
		//top.showFault('此账户没有足够资金，请重新输入！')
		alert('此账户没有足够资金，请重新输入！');
		document.forms[0].amount.value="";
    	document.forms[0].upperAmount.value="";
		return;
	}
	if (data == 1){
		//top.showFault('请输入转出金额！');
		alert('请输入转出金额！');
		document.forms[0].amount.focus();
    	document.forms[0].upperAmount.value="";
		return; 
	} 
}
function kd() {
	var ss=getObj("amount").value;
	ss = ss.replace(/ /g,"");
	if (ss=="") {
		getObj("upperAmount").value="";
		return;
	}
	
	var sDispMsg = getChineseCurrencyString(ss);
	if(sDispMsg==-1) sDispMsg="错误的金额!";
	if(sDispMsg==-2) sDispMsg="太长的金额!";
	getObj("upperAmount").value=sDispMsg;
}

function numToChinese(num) {
    var chinese = Chinese(num);
    document.getElementById("chinese").innerText= "大写："+chinese+"元";
}

	function getSubAcctBal() {
		var subAcctId = document.getElementById("subAccountId").value;
		accountTemplate.accountMoney(subAcctId, setBalance);
	}

	function setBalance(money) {
		getObj('subaccountBal').innerHTML = money + '元';
	}
</script>
<div id="main">
	<div class="content_right">
		<div style="width:745px;margin-left:10px;">
			<div class="titleinfo">
				账户提现
			</div>
			<div class="edit_pass">
				<table width="100%" border="0" align="center" cellpadding="5"
					cellspacing="1">
					<html:form action="drawToSelf" method="post">
						<html:hidden property="step" />
						<html:hidden property="actionType" />
						<!--提现子账户 -->
						<tr>
							<td width="25%" align="right" height="35px;">
								提现子账户：
							</td>
							<td width="75%" height="35px;">
								<div class="select">
									<div>
										<html:select property="subAccountId" styleId="subAccountId"
											onchange="getSubAcctBal()">
											<html:options collection="subAccounts" property="id"
												labelProperty="accountName" />
										</html:select>
									</div>
								</div>
							</td>
						</tr>
						<!--子账户余额 -->
						<tr>
							<td width="25%" align="right" height="35px;">
								子账户余额：
							</td>
							<td width="75%" height="35px;">
								<span id="subaccountBal" class="lan"></span>
							</td>
						</tr>
						<!--收款银行账户名称 -->
						<tr>
							<td align="right" height="35px;">
								收款银行账户名称：
							</td>
							<td height="35px;">
								<html:select property="accountBankId" styleId="accountBankId">
									<html:options collection="accountBankList" property="id" labelProperty="accountName" />
								</html:select>
								&nbsp;&nbsp;&nbsp;
								<%--<a
									href="<%=path%>/page/myspace/accountList.do?modifyType=moveOut"
									class="menuTextBlue">添加银行帐户</a>
							--%></td>
						</tr>
						<!--收款银行账户账号  -->
						<tr>
							<td align="right" height="35px;">
								收款银行账户账号：
							</td>
							<td height="35px;">
								<span class="lan">
									<ad:BankCardNum name="accountBankList" filter="false" inputId="accountBankId" />
								</span>
							</td>
						</tr>

						<!--提现金额  -->
						<tr>
							<td align="right" height="35px;">
								<span class="orang12b">*</span> 提现金额：
								
							</td>
							<td height="35px;">
								<html:text property="amount" alt="提现金额" size="50"
									styleClass="inputStyle"
									onblur="if(checkDecimalInput(this,0)&&document.all.subAccountId.value!=''){accountTemplate.compareAccountMoney(document.forms[0].subAccountId.value,this.value, function(data){updatePrompt(data);})} ; tomoney('forms[0]','amount','hideTransAmt');kd();"
									onkeyup="kd();" onchange="kd();" />
								元
								<img src="<%=path%>/images/money.gif" width="17" height="17"
									style="cursor:hand" title="请使用计算器，计算提现金额"
									onclick="amountSelect();" />
								<input type="hidden" name="hideTransAmt" value="" />
							</td>
						</tr>
						<!--提现金额大写  -->
						<tr>
							<td align="right" height="35px;">
								提现金额大写：
							</td>
							<td height="35px;">
								<input type="text" name="upperAmount" size="50"
									class="inputStyleNoborder" style="background:#F6F6F6;" readonly />
							</td>
						</tr>
						<!--手续费收取方法  -->
						<tr>
							<td align="right" height="35px;">
								手续费收取方法：
							</td>
							<td height="35px;">
							
								<span class="lan"><bean:write name="feeRatioMode" /></span>
							</td>
						</tr>
						<!--资金用途  -->
						<tr>
							<td align="right" height="35px;">
								<span class="orang12b">*</span> 资金用途：
								
							</td>
							<td height="35px;">
								<html:text property="purpose" alt="资金用途" maxlength="85"
									size="50" styleClass="inputStyle" onblur="killSpace(this)" />
								<span class="lan">(最长85个字符)</span>
							</td>
						</tr>
						<!--备注  -->
						<tr>
							<td align="right" height="35px;">
								备注：
							</td>
							<td height="35px;">
								<html:textarea property="remark" rows="5" cols="35"
									style="border:1px solid #ccc;" />
								<span class="lan">(最长85个字符)</span>
							</td>
						</tr>
						<tr>
							<td align="right" height="35px;">
							</td>
							<td height="35px;">
								<font color="#FF0000"><html:errors /> </font>
							</td>
						</tr>
					</html:form>
					<tr>
						<td height="55" align="right" height="35px;">
							&nbsp;
						</td>
						<td height="35px;" height="35px;">
							<input name="button2" type="button" class="button_style"
								onclick="submitProcess();" value="下一步" />
						</td>
					</tr>
				</table>
				<table width="100%" border="0" align="center" cellpadding="7"
										cellspacing="1" bgcolor="#f9e277" style="margin:10px 0;">
										<tr>
											<td bgcolor="#fffdf5">
												<table width="100%" border="0" cellpadding="3"
													cellspacing="0">
													<tr>
														<td width="3%" height="25" valign="top"
															style="border-bottom:1px solid #ccc;"></td>
														<td width="97%" align="left" class="red12b"
															style="border-bottom:1px solid #ccc;">
															特别提醒
														</td>
													</tr>
								<tr>
									<td valign="top">
										&nbsp;
									</td>
									<td align="left" class="font_gray">
										如果需要转出资金到他人银行账户，请使用
										<a href="#"
											onclick="loading('<%=path%>/route.do?modual=pay$drawToOther')">账户直付</a>
										功能
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript" src="<%=path%>/js/layer.js"></script>
<script language="JavaScript" type="text/JavaScript">
function closeLayer(returnValue, type){
	hideLayer();
	if(type=="amount"){
		document.forms[0].amount.value=returnValue;
		document.forms[0].amount.focus();
		kd();
	}
}

function amountSelect(){
 	agiledata.getUserInternal(amountPopup);
}
function amountPopup(data) {
  	if(data) {
	 	openLayer("<%=path%>/page/common/simpleCalculator.jsp",400,200,false);
	} else {
		location.href="<%=path%>/page/util/session_invalid.jsp";
	}      
}
getSubAcctBal();
</script>
